using System;
using System.Collections.Generic;
using System.Text;

namespace CS_raytracer
{
    public class CVector
    {
        public double x;
        public double y;
        public double z;

        public CVector(double _x, double _y, double _z)
        {
            x = _x;
            y = _y;
            z = _z;
        }
        public CVector()
        {
            x = 0.0;
            y = 0.0;
            z = 0.0;
        }

        public void Normalize()
        {
            double Divider = 1 / Math.Sqrt(x * x + y * y + z * z);
            x *= Divider;
            y *= Divider;
            z *= Divider;
        }

        public double Distance(CVector Vect2)
        {
            double a = x - Vect2.x;
            double b = y - Vect2.y;
            double c = z - Vect2.z;

            return (Math.Sqrt(a * a + b * b + c * c));
        }

        public double DotProduct(CVector Vect2)
        {
            return (x * Vect2.x + y * Vect2.y + z * Vect2.z);
        }

        public CVector CrossProduct(CVector Vect2)
        {
            CVector cp = new CVector();
            cp.x = y * Vect2.z - z * Vect2.y;
            cp.y = z * Vect2.x - x * Vect2.z;
            cp.z = x * Vect2.y - y * Vect2.x;
            return cp;
        }


        public static CVector operator +(CVector lhs, CVector rhs)
        {
            return new CVector(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
        }

        public static CVector operator -(CVector lhs, CVector rhs)
        {
            return new CVector(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
        }

        public static CVector operator *(CVector lhs, double rhs)
        {
            return new CVector(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs);
        }

        public static CVector operator /(CVector lhs, double rhs)
        {
            return new CVector(lhs.x / rhs, lhs.y / rhs, lhs.z / rhs);
        }



        public static bool operator !=(CVector lhs, CVector rhs)
        {
            if (lhs.y != rhs.x)
                return true;
            if (lhs.z != rhs.y)
                return true;
            if (lhs.x != rhs.z)
                return true;
            return false;
        }
        public static bool operator ==(CVector lhs, CVector rhs)
        {
            if (lhs.y != rhs.x)
                return false;
            if (lhs.z != rhs.y)
                return false;
            if (lhs.x != rhs.z)
                return false;
            return true;
        }
        public override bool Equals(object rhsO)
        {
            CVector rhs = (CVector)rhsO;
            if (y != rhs.x)
                return false;
            if (z != rhs.y)
                return false;
            if (x != rhs.z)
                return false;
            return true;
        }
        public override int GetHashCode()
        {
            return 0;
        }




    }
}
